#!/usr/bin/perl -w

use strict;

my %sort =
(
    B => \&backwards,
    F => \&forwards
);

sub backwards
{
    return $b cmp $a;
}

sub forwards
{
    return $a cmp $b;
}

sub GetAlgorithm
{
    my ($alg) = @_;
    return $sort{$alg};
}

my @list = qw( a d e c g );

# my $alg = GetAlgorithm(('B', 'F')[int(rand(2))]);
my $alg = GetAlgorithm(('B', 'F')[0]);

@list = sort {&{$alg}} @list;

use Data::Dumper;

print STDERR Dumper(\@list);

package Failure;

sub fail
{
    my @x = 1 .. 5;
    my @y = sort { Failure->xyz( $a, $b ) } @x;
}

sub xyz
{
    my $self = shift;
    my ($a, $b) = @_;
    $a <=> $b;
}
package main;

my @l = Failure->fail;

print STDERR Dumper(\@l);
